import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'zone_page.dart';

class RankController extends GetxController with GetTickerProviderStateMixin {
  bool flag = false;
  late RxList tabs = [].obs;
  RxInt initialIndex = 0.obs;
  late TabController tabController;

  late List<Widget> tabsPageList;

  List tabsConfig = [
    {
      'icon': const Icon(
        Icons.live_tv_outlined,
        size: 15,
      ),
      'label': '全站',
      'type': "all",
      'page': const ZonePage(rid: 0),
    },
    {
      'icon': const Icon(
        Icons.live_tv_outlined,
        size: 15,
      ),
      'label': '国创相关',
      'type': 'creation',
      'page': const ZonePage(rid: 168),
    },
    {
      'icon': const Icon(
        Icons.live_tv_outlined,
        size: 15,
      ),
      'label': '动画',
      'type': 'animation',
      'page': const ZonePage(rid: 1),
    }
  ];
  @override
  void onInit() {
    super.onInit();
    // 进行tabs配置
    setTabConfig();
  }

  void setTabConfig() async {
    tabs.value = tabsConfig;
    initialIndex.value = 0;

    tabsPageList = tabs.map<Widget>((e) => e['page']).toList();

    tabController = TabController(
      initialIndex: initialIndex.value,
      length: tabs.length,
      vsync: this,
    );
  }

  @override
  void onClose() {
    super.onClose();
  }
}
